package br.com.deployment.mobile.activity;

import br.com.deployment.mobile.NewEyre;
import br.com.deployment.mobile.R;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends Activity {

	private Button newEyre;
	private Button viewAllEyre;
	private Button synchronize;
	private Button configuration;

	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		newEyre = (Button) findViewById(R.id.new_eyre_button);
		viewAllEyre = (Button) findViewById(R.id.view_all_eyre_button);
		synchronize = (Button) findViewById(R.id.synchronize_button);
		configuration = (Button) findViewById(R.id.configuration_button);
		
		newEyre.setOnClickListener(buttonListener);
		viewAllEyre.setOnClickListener(buttonListener);
		synchronize.setOnClickListener(buttonListener);
		configuration.setOnClickListener(buttonListener);
	}
	
	

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}
	
	OnClickListener buttonListener = new OnClickListener() {
		@Override
		public void onClick(View v) {
			if (v == newEyre) {
				showMessage("Novo");
				newEyre();
			}else if (v == viewAllEyre) {
				showMessage("Ver Todos");
				viewAllEyre();
			}else if (v == synchronize) {
				showMessage("Sincronizar");
				synchronize();
			}else if (v == configuration) {
				showMessage("Configurações");
				configuration();
			}
		}
	};
	
	private void showMessage(String msg){
		Toast.makeText(getApplicationContext(), msg,
				Toast.LENGTH_SHORT).show();
	}
	
	private void newEyre(){
		Intent intent = new Intent(MainActivity.this, NewEyre.class);
		startActivity(intent);
	}
	
	private void viewAllEyre(){
		Intent intent = new Intent(MainActivity.this, NewEyre.class);
		startActivity(intent);
	}
	
	private void configuration(){
		Intent intent = new Intent(MainActivity.this, NewEyre.class);
		startActivity(intent);
	}
	
	private void synchronize(){
		Intent intent = new Intent(MainActivity.this, NewEyre.class);
		startActivity(intent);
	}
	
}
